import UIKit

// Array
var a = [12, 2, 3]
var b: [String] = ["Fack", "Jerry"]
var c: Array<Double> = [3.3, 9.2, 0.32]
var d = Array(repeating: -1, count: 5)

c[0]
c[0] = 4.5
c.append(1.1)
print(c)
c.insert(5.0, at: 2)
print(c)
//可以使用A+B组合两个数组
c+=[23.8,99.0]//[4.5, 9.2, 5.0, 0.32, 1.1, 23.8, 99.0]

c.replaceSubrange(1...3, with: [1,2,3])//[4.5, 1.0, 2.0, 3.0, 1.1, 23.8, 99.0]

//c.sort(by: >)
c.sort()//[1.0, 1.1, 2.0, 3.0, 4.5, 23.8, 99.0]
print(c)

let newC = c.filter { item in
  item>20
}
//newC:[23.8, 99.0]

//循环
let loop = ["a","b","c","d","e"]
for index in (1..<loop.count).reversed() {
  print(loop[index])
}
